package com.android.rxmvpdemo;

import com.jaydenxiao.common.base.BasePresenter;
import com.jaydenxiao.common.baserx.RxHelper;
import com.jaydenxiao.common.baserx.RxSubscriber;
import com.jaydenxiao.common.manager.ServiceManager;

import java.util.List;

import io.reactivex.disposables.Disposable;

/**
 * Created by ${yue} on 2017/9/30 0030.
 */

public class MainPresenter extends BasePresenter<MainView> {
    
    public void getBannerList(String type){
        ServiceManager.create(ApiService.class).getBannerList(type)
                        .compose(RxHelper.handleResult())
                .compose(mView.bindToLife())
               .subscribe(new RxSubscriber<List<Banner>>(mContext,false) {
                   @Override
                   protected void subscribe(Disposable d) {
                       addSubscribe(d);
                   }
                   @Override
                protected void _onNext(List<Banner> banners) {
                     mView.showbannerList(banners);
                 }
               }
        );
       
    }
}
